import { store } from 'src/store'

export default () => (target) => {
  target.prototype._onShareAppMessage = target.prototype.onShareAppMessage
  target.prototype.onShareAppMessage = function () {
    if (target.prototype._onShareAppMessage) {
      return target.prototype._onShareAppMessage()
    } else {
      const { userInfo } = store.getState().user
      let path = '/pages/index/index'
      if (userInfo.uid) {
        path = `/pages/index/index?pid=${userInfo.uid}`
      }
      return {
        title: '发现一家好店铺，分享给你～',
        path: path,
        imageUrl:
          'http://image.tocj1314.com/0746056800564c178edcc3c9bfdf0be2.png',
      }
    }
  }
}
